<?php
function text_alignment($str,$length){
    $str = trim($str);
    $str = "'".$str."'";
    $str_length = mb_strlen($str,'utf-8');
    if($str_length < $length){
        for($i=0;$i<$length-$str_length;$i++){
            $str .= " ";
        }
    }

    return $str;
}